function getRequestObject() {
	if (window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else {
		return null;
	}
}

function sendRequest(url, param, method, fn) {
	if (!method) {
		method = "POST";
	}

	var request = getRequestObject();
	request.onreadystatechange = function() { fn(request); };
	
	request.open(method, url, true);
	request.send(null);
}

function getTicketList(url) {
	var handleTicketListResponse = function(request) {
		if ((request.readyState == 4) && (request.status == 200)) {
			var projectTicketList = document.getElementById("ProjectTicketList");
			if (projectTicketList) {
				projectTicketList.innerHTML = request.responseText;
			}
		}
	};
	
	sendRequest(url, null, "GET", handleTicketListResponse);
}

function checkEmail(url, id) {
	var req = getRequestObject();
	if (req != null) {
		req.onreadystatechange = function() { showMailStatus(req, "emailStatus"); };
		req.open("POST", url, true);
		req.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		var email = document.getElementById("email").value;
		req.send("email=" + email);
	}
}

function showMailStatus(request, id) {
	if((request.readyState == 4) && (request.status == 200)) {
		document.getElementById(id).innerHTML = request.responseText;
	}
}